package day03test;

public class OperDemo {
    public static void main(String[] args) {
        //1. 算数运算符,+,-,*,/,%,++,--
        System.out.println(2%5);//2
        System.out.println(5%2);//1
        System.out.println(8%2);//0

        //关于++,--的自用和被用
        int a=1,b=2;
        a++;
        ++b;
        System.out.println(a);//2
        System.out.println(b);//3
        int c=1,d=1;
        c--;
        --d;
        System.out.println(c);//0
        System.out.println(d);//0
        int e=1,f=1;
        System.out.println(e++);//1
        System.out.println(++f);//2
        int g=1,h=1;
        System.out.println(g--);//1
        System.out.println(--h);//0

        //2. 关系运算符,>,<,>=,<=,==,!=
        System.out.println(2>1);//true
        System.out.println(2<1);//false
        System.out.println(2>=1);//true
        System.out.println(2<=1);//false
        System.out.println(2==1);//false
        System.out.println(2!=1);//true

        //3. 逻辑运算符  &&,||,!
        //&&
        System.out.println(true&&true);//true
        System.out.println(true&&false);//false
        System.out.println(false&&true);//false
        System.out.println(false&&false);//false
        //||
        System.out.println(true||true);//true
        System.out.println(true||false);//true
        System.out.println(false||true);//true
        System.out.println(false||false);//false
        //!
        System.out.println(!true);//false
        //短路的演示
        //&&短路
        int a1=5,a2=10,a3=5;
        boolean a4=a1>a2&&a3++>4;//false
        System.out.println(a4);//false
        System.out.println(a3);//5短路了
        //||短路
        int b1=5,b2=10,b3=5;
        boolean b4=b2>b1||b3++>4;//true
        System.out.println(b4);//true
        System.out.println(b3);//5

        //字符串拼接
        System.out.println("a"+"b"+b3);//ab5
        System.out.println(10+2+""+39);//1239
        System.out.println(""+1+9+9);//199
        System.out.println(1+2+3+4+"");//9

        //三目表达式
        int num=5;
        int flag=num>0?1:-1;
        System.out.println(flag);//1

        int a6=5,a7=8;
        int max=a6>a7?a6:a7;
        System.out.println(max);//8

        //if语句
        double mounyall=0;
        double palyfortrue=0;
        if(mounyall>2000){
            palyfortrue*=0.5;
        } else if (mounyall>1000) {
            palyfortrue*=0.7;
        } else if (mounyall>500) {
            palyfortrue*=0.8;
        }else {
            palyfortrue*=0.9;
        }
        System.out.println("palyfortrue"+palyfortrue);
    }
}
